<?php namespace Admin\Model;
use Hdphp\Model\Model;

class Setting extends Model{
	//指定表名,固定写法
    protected $table = "setting";
	//自动完成

public function store(){
		//执行自动验证
		if($this->create()){
			$datac = Db::table('category')->join('setting','cid','=','stcid')->where('pid=0')->get();
			foreach ($datac as $k => $v) {
				$c[] = $v['cid'];
			}
			$data = array();
			$stid = Q("post.stid",0,'intval');
			$index_sth = Q("post.index_sth",array());
			$index_a = Q("post.index_a",array());
			$index_list = Q("post.index_list",array());
			$stcid = Q("post.stcid",0,'intval');
			$pid = Q("post.pid",0,'intval');
			foreach ($stid as $key => $value) {
					if($pid[$value]==0){
						$data = array(
						'stid'=>$value,
						'stcid'=>$stcid[$value],
						'index_sth'=>$index_sth[$value],
						);
					}else{
						$data = array(
						'stid'=>$value,
						'stcid'=>$stcid[$value],
						'index_a'=>$index_a[$value],
						'index_list'=>$index_list[$value],
						);
					}$this->save($data);
			}
			
			return true;
		}
		return false;
	}
}




